package com.ruoyi.web.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.business.domain.MfuAppInfo;
import com.ruoyi.web.business.service.IMfuAppInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用信息Controller
 * 
 * @author ruoyi
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/appInfo")
public class MfuAppInfoController extends BaseController
{
    @Autowired
    private IMfuAppInfoService mfuAppInfoService;

    /**
     * 查询应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MfuAppInfo mfuAppInfo)
    {
        startPage();
        List<MfuAppInfo> list = mfuAppInfoService.selectMfuAppInfoList(mfuAppInfo);
        return getDataTable(list);
    }

    /**
     * 导出应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:export')")
    @Log(title = "应用信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MfuAppInfo mfuAppInfo)
    {
        List<MfuAppInfo> list = mfuAppInfoService.selectMfuAppInfoList(mfuAppInfo);
        ExcelUtil<MfuAppInfo> util = new ExcelUtil<MfuAppInfo>(MfuAppInfo.class);
        util.exportExcel(response, list, "应用信息数据");
    }

    /**
     * 获取应用信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mfuAppInfoService.selectMfuAppInfoById(id));
    }

    /**
     * 新增应用信息
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:add')")
    @Log(title = "应用信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MfuAppInfo mfuAppInfo)
    {
        return toAjax(mfuAppInfoService.insertMfuAppInfo(mfuAppInfo));
    }

    /**
     * 修改应用信息
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:edit')")
    @Log(title = "应用信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MfuAppInfo mfuAppInfo)
    {
        return toAjax(mfuAppInfoService.updateMfuAppInfo(mfuAppInfo));
    }

    /**
     * 删除应用信息
     */
    @PreAuthorize("@ss.hasPermi('system:AppInfo:remove')")
    @Log(title = "应用信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mfuAppInfoService.deleteMfuAppInfoByIds(ids));
    }
}
